# # 财务
# # 添加应收款06
# # (描述信息含特殊字符)
# from selenium import webdriver  # 调用webdriver
# from selenium.webdriver.common.by import By  # 引入by模块
# from time import sleep  # 调用sleep
# from selenium.webdriver.support.select import Select
#
# driver = webdriver.Chrome()  # 打开浏览器
# try:
#     driver.maximize_window()  # 最大化浏览器
#     driver.get("http://192.168.1.79/")  # 访问crm后台
#     cookie = {"name": "PHPSESSID", 'value': 'p5tsh1p53643ic9ld0la870gm5'}
#     driver.add_cookie(cookie)
#     driver.get("http://192.168.1.79/crm/index.php?m=finance&a=add&t=receivables")  # 访问crm添加产品页面
#     # 定位器
#     # btn_locator=(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[3]/a[1]') #添加应收款
#     ys_name_locator = (By.XPATH, "/html/body/div[5]/div[2]/div/form/table/tbody/tr[2]/td[2]/input")  # 应收款名
#     contract_name_locator = (By.ID, "contract_name")  # 合同
#     contract_locator = (By.CSS_SELECTOR, "#data > tr > td:nth-child(1) > input[type=radio]")
#     ui_locator = (By.XPATH, "/html/body/div[8]/div[3]/div/button[1]")  # 合同ok按钮
#     pay_time_locator = (By.ID, "pay_time")  # 收款时间
#     description_locator = (By.XPATH, "/html/body/div[5]/div[2]/div/form/table/tbody/tr[9]/td[2]/textarea")  # 收款时间
#     sk_submit_locator = (By.NAME, "submit")
#     # 查找应收元素
#     ys_name_element = driver.find_element(*ys_name_locator).send_keys("冷吃兔")
#     sleep(2)
#     contract_name_element = driver.find_element(*contract_name_locator).click()
#     sleep(2)
#     contract_element = driver.find_element(*contract_locator).click()
#     sleep(2)
#     ui_element = driver.find_element(*ui_locator).click()
#     sleep(2)
#     pay_time_element = driver.find_element(*pay_time_locator)
#     pay_time_element.clear()
#     pay_time_element.send_keys("2022-09-13")
#     sleep(2)
#     driver.find_element(*description_locator).send_keys("教育局通&*……%￥#￥%……&&知中秋节放假3天")
#     sleep(2)
#     driver.find_element(*sk_submit_locator).click()
# except:
#     raise
# finally:
#     sleep(5)  # 暂停五秒，并关闭浏览器
#     driver.quit()
